﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MvcJqGrid;
using PagedList;
using WebApp.Commons;
using WebApp.Data;
using WebApp.Models;
using WebApp.Services;

namespace WebApp.Controllers
{
    public class SupplierController : Controller
    {
        //
        // GET: /Supplier/

        private SupplierService _service;

        public ActionResult Index()
        {
            return View();
        }
        /*
//        public JsonResult GetUsers(GridSettings gridSettings, string keyword)
//        {
//            _service = new SupplierService();
//
//            var realCount = 0;
//
//            var datas = _service.GetUsers(gridSettings.PageIndex,
//                                          gridSettings.PageSize,
//                                          gridSettings.SortColumn,
//                                          gridSettings.SortOrder,
//                                          keyword,
//                                          ref realCount);
//
//            var totalBUs = realCount;
//            var totalPage = totalBUs / gridSettings.PageSize;
//
//            if (totalPage > Convert.ToInt32(totalPage))
//            {
//                totalPage = totalPage + 1;
//            }
//
//            var jsonData = new
//            {
//                total = Convert.ToInt32(totalPage),
//                page = gridSettings.PageIndex,
//                records = totalBUs,
//                rows = (
//                            from c in datas
//                            select new
//                            {
//                                id = c.supplier_id,
//                                cell = new[] {
//                                            c.supplier_id.ToString(CultureInfo.InvariantCulture),
//                                            c.supplier_name,
//                                            c.supplier_address,
//                                            c.supplier_province,
//                                            c.supplier_zipcode,
//                                            c.supplier_country,
//                                            c.supplier_tel_no,
//                                            c.supplier_fax_no,
//                                            c.supplier_email,
//                                            c.supplier_tax_no,
//                                            c.supplier_status,
//                                            c.supplier_create_date.HasValue ? c.supplier_create_date.Value.ToLongDateString() : "",
//                                            c.supplier_detail
//                                            }
//                            }
//                        ).ToPagedList(1, gridSettings.PageSize).ToArray()
//            };
//
//            return Json(jsonData, JsonRequestBehavior.AllowGet);
//        }

//        public JsonResult Update(tbl_supplier oModel, FormCollection formCollection)
//        {
//            _service = new SupplierService();
//
//            var isPass = false;
//            var iMessage = string.Empty;
//
//            var operation = formCollection["oper"];
//
//            if (operation.Equals("add") || operation.Equals("edit"))
//            {
//                _service.UpdateSupplier(oModel);
//            }
//            else if(operation.Equals("del"))
//            {
//                _service.Delete(oModel);
//            }
//
//            return Json(new { isPass, iMessage });
//        }

        public string GetCountrySelectList()
        {
            var sTag = DataProvider.GetCountry().Aggregate("<select>", (current, country) => current + "<option value='" + country.country_id + "'>" + country.country_name + "</option>");

            return sTag + "</select>";
        }*/
    }
}
